Player.from_userid caching#297
Conversation
satoon101
commented
Jan 4, 2020
- Added caching boolean argument for Player.from_userid.
|
This came about because I was testing GunGame this morning and encountered an issue with gg_multi_level. I narrowed down the issue to the fact that the cache was causing me to get the same instance of _MultiLevelPlayer every time. There were other ways to fix it and use the cache, but I at least thought it would be a good idea to allow for caching=False through from_userid. |
|
Yes, makes sense for that method to forward that keyword. We should also add it to EDIT : I suggest to change that section to: # Set whether or not this class is caching its instances by default
try:
cls._caching = signature(
vars(cls)['__init__']
).parameters['caching'].default
except KeyError:
cls._caching = vars(cls).get('caching', False)To get the following behaviours: class MyEntity(Entity):
pass
print(MyEntity.caching) # False
class MyEntity(Entity):
caching = True
print(MyEntity.caching) # True
class MyEntity(Entity):
def __init__(self, index, caching=True):
pass
print(MyEntity.caching) # TrueAlso, |
…tly enable it (to retain backward compatibility for existing classes that were not implemented with caching in mind). Added caching keyword to Entity.from_inthandle. Fixed Player.from_userid not following the caching state of the current class unless explicitly specified. Added missing documentation.
…r instances by default (introduced by the backward compatibility fix added into #297).